'use strict';
const Service = require('egg').Service;

//
class Mining2Service extends Service {
  // 挖矿2合约监听的封装
  async scanEvent2(event_name, min_timestamp, max_timestamp) {
    const { app, ctx, service } = this;
    const tronGrid = app.BSC.TronGrid;
    const contractAddress = app.BSC.Mining2Address;
    // 监听这个事件的时间区间之内的所有事件,但是不能超过200条
    const options1 = {
      event_name: event_name,
      only_confirmed: false,
      // block_number: '18124224',
      min_timestamp: min_timestamp,
      max_timestamp: max_timestamp,
      limit: 200,
    };
    const eventRes1 = await tronGrid.contract.getEvents(contractAddress, options1);
    return eventRes1.data;
  }



}

module.exports = Mining2Service;
